use "C:\Users\jkbrueck\Documents\STATA\Fuel 4\US data\Calvin3_A_car.dta", clear

forvalues i = 2014(1)2018 {
gen d`i' = 0
replace d`i' = 1 if y`i' == "A"
}

forvalues i = 2014(1)2018 {
egen count`i' = total(d`i'), by(airline type)
}

sort airline type
keep airline type count2014-count2018

collapse (mean) count2014-count2018, by(airline type)

save "C:\Users\jkbrueck\Documents\STATA\Fuel 4\US data\type_count.dta", replace